// components/smart_time/smart_time.js
const computedBehavior = require('miniprogram-computed');
Component({
  /**
   * 组件的属性列表
   */
  behaviors: [computedBehavior],
  watch:{
    custom_time(current){
      if(current.start.length>0){
        this.time_handle();
      }
    }
  },
  properties: {
    custom_time: {
      type: Object,
      value: {
        start: [0, 0], //开始小时,开始分钟
        end: [23, 59], //结束小时,结束分钟
      }
    },
    new_time: {
      type: String
    },
    new_time_state: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    appointment: '',
    appointment_show: '',
    multiArray: [],
    multiIndex: [0, 0, 0, 0, 0],
    after_day: 7, //后几天
    //时间转换
    customformatTimeTrans: (time, type = false) => {
      const data = new Date(time);
      let revertime = {};
      let month = '';
      let day = '';
      let hours = '';
      let mi = '';
      let year = "";
      if (data.getFullYear() < 10) {
        year = '0' + data.getFullYear();
      } else {
        year = data.getFullYear();
      }
      if (data.getHours() < 10) {
        hours = '0' + data.getHours();
      } else {
        hours = data.getHours();
      }
      if (data.getMinutes() < 10) {
        mi = '0' + data.getMinutes();
      } else {
        mi = data.getMinutes();
      }
      if ((data.getMonth() + 1) < 10) {
        month = '0' + (data.getMonth() + 1);
      } else {
        month = data.getMonth() + 1;
      }
      if (data.getDate() < 10) {
        day = '0' + data.getDate();
      } else {
        day = data.getDate();
      }
      revertime.m = month;
      revertime.d = day;
      revertime.h = hours;
      revertime.mi = mi;
      revertime.y = year;
      // console.log(data, time, revertime)
      if (type) {
        return revertime.y + '-' + revertime.m + '-' + revertime.d + ' ' + revertime.h + ":" + revertime.mi;
      }
      return revertime;
    }
  },
  // 以下是旧式的定义方式，可以保持对 <2.2.3 版本基础库的兼容
  attached: function () {
    // 在组件实例进入页面节点树时执行

  },
  /**
   * 组件的方法列表
   */
  methods: {
    //滑动时间选择器
    bindMultiPickerColumnChange: function (e) {
      let that = this;
      const {
        column,
        value
      } = e.detail;
      // console.log(column, value);
      var data = {
        multiArray: this.data.multiArray,
        multiIndex: this.data.multiIndex
      };
      let month = [];
      let day = [];
      let hour = [];
      let mi = [];
      // let mi_data = ['00', '10', '20', '30', '40', '50'];
      let mi_data = [];
      for (var i = '0'; i < 60; i++) {
        mi_data.push(i >= 10 ? `${i}` : `0${i}`)
      }

      function match_time_handle() { //当前时间处理
        let start_time = Number(that.data.custom_time.start[0]) > new Date(that.data.new_time_state ? that.data.new_time : new Date()).getHours() ? Number(that.data.custom_time.start[0]) : new Date(that.data.new_time_state ? that.data.new_time : new Date()).getHours();
        for (let i = start_time; i <= that.data.custom_time.end[0]; i++) {
          if (i == that.data.custom_time.end[0]) {
            if (that.data.custom_time.end[1] >= 10) {
              hour.push(i >= 10 ? `${i}时` : `0${i}时`);
            }
          } else {
            hour.push(i >= 10 ? `${i}时` : `0${i}时`);
          }
        }
        if (Number(that.data.custom_time.start[0]) > new Date(that.data.new_time_state ? that.data.new_time : new Date()).getHours()) { //开始时间大于当前时间，使用开始时间
          if (hour.length == 1) { //一开始时间为起始,结束分钟为结束时间
            for (var i = 0; i < app.globalData.end[0]; i++) {
              if (mi_data[i] >= that.data.custom_time.start[1] && mi_data[i] <= that.data.custom_time.end[1]) {
                mi.push(`${mi_data[i]}分`)
              }
            }
          } else if (hour.length > 1) { //使用开始时间，结束时间为50分钟
            for (var i = 0; i < mi_data.length; i++) {
              if (mi_data[i] >= that.data.custom_time.start[1]) {
                mi.push(`${mi_data[i]}分`)
              }
            }
          }
        } else { //开始时间小于当前时间, 使用当前时间
          if (hour.length == 1) { //当前时间为起始,结束分钟为结束时间
            for (var i = 0; i < mi_data.length; i++) {
              if (mi_data[i] >= new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes() && mi_data[i] <= that.data.custom_time.end[1]) {
                mi.push(`${mi_data[i]}分`)
              }
            }
          } else if (hour.length > 1) { //使用当前时间，结束时间为50分钟
            for (var i = 0; i < mi_data.length; i++) {
              if (mi_data[i] >= new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes()) {
                mi.push(`${mi_data[i]}分`)
              }
            }
          }
        }
      }

      function next_time_handle() { //以后的时间处理
        for (let i = Number(that.data.custom_time.start[0]); i <= that.data.custom_time.end[0]; i++) {
          hour.push(i >= 10 ? `${i}时` : `0${i}时`);
        }
        for (let i = 0; i < mi_data.length; i++) {

          if (mi_data[i] >= that.data.custom_time.start[1]) {

            mi.push(`${mi_data[i]}分`);
          }
        }
      }
      // console.log( `${data.multiArray[0][data.multiIndex[0]]}-${data.multiArray[1][data.multiIndex[1]]}-${data.multiArray[2][data.multiIndex[2]]} ${data.multiArray[3][data.multiIndex[3]]}:${data.multiArray[4][data.multiIndex[4]]}:00秒`)
      switch (column) {
        case 0: //对年进行处理
          if (value == 0) { //当选择本年时
            //计算当年剩下月份
            let mon_date = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMonth() + 1;
            // console.log(mon_date, typeof mon_date);
            for (var i = mon_date; i <= 12; i++) {
              month.push(`${i}月`);
            }
            //计算当月剩下多少天
            let day_date = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate();
            let day_total = new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getFullYear(), new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMonth() + 1, 0).getDate();
            for (var i = day_date; i <= day_total; i++) {
              day.push(`${i}日`);
            }
          } else { //当选择下年时
            let num_total = new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + that.data.after_day)).getMonth() + 1;
            let day_num_total = new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + that.data.after_day)).getDate();
            for (var i = 1; i <= num_total; i++) {
              month.push(`${i}月`);
            }
            // console.log(new Date(d.getFullYear() + value, 1, 0));
            for (var j = 1; j < day_num_total; j++) {
              day.push(`${j}日`);
            }
            // console.log(day);
          };
          //对小时和分钟的处理
          if (value == 0) {
            match_time_handle();
          } else {
            next_time_handle();
          }
          data.multiArray[1] = month;
          data.multiArray[2] = day;
          data.multiArray[3] = hour;
          data.multiArray[4] = mi;
          data.multiIndex[1] = 0;
          data.multiIndex[2] = 0;
          data.multiIndex[3] = 0;
          data.multiIndex[4] = 0;
          break;
        case 1: //对月份进行处理
          let middle_year = data.multiArray[0][data.multiIndex[0]];
          let middle_month = data.multiArray[1][value];
          const reg_y = new RegExp('年', 'gi');
          middle_year = middle_year.replace(reg_y, '');
          const reg_m = new RegExp('月', 'gi');
          middle_month = middle_month.replace(reg_m, '');
          if (value == 0) { //本月处理
            //本年本月处理
            if (data.multiIndex[0] == 0) {
              //计算当月剩下多少天
              let day_total = new Date(middle_year, middle_month, 0).getDate();
              for (var i = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate(); i <= day_total; i++) {
                day.push(`${i}日`);
              }
              if (data.multiIndex[2] == 0) { //本年本月本日
                match_time_handle();
              } else {
                next_time_handle();
              }
            } else {
              //计算当月剩下多少天
              let day_total = new Date(middle_year, middle_month, 0).getDate();

              for (var i = 1; i <= day_total; i++) {
                day.push(`${i}日`);
                // console.log(i);
              }
              next_time_handle();
            }
          } else { //下月处理
            // console.log(data.multiArray[0][data.multiIndex[0]], data.multiArray[1][value]);

            // let day_total = new Date(middle_year, middle_month, 0).getDate();
            // this.data.after_day
            let num_total = new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + this.data.after_day)).getDate()
            //求下月到期限前，剩餘多少天
            for (var i = 1; i < num_total; i++) {
              day.push(`${i}日`);
              // console.log(i);
            }
            next_time_handle();
            // console.log(middle_year, middle_month);
          };
          data.multiArray[3] = hour;
          data.multiArray[2] = day;
          data.multiArray[4] = mi;
          data.multiIndex[2] = 0;
          data.multiIndex[3] = 0;
          data.multiIndex[4] = 0;
          break;
        case 2: //对当年，当月当日处理
          // console.log(data.multiArray[2][0].split("日")[0])
          if (value == 0 && (data.multiArray[2][0].split("日")[0] == new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate())) {
            if (data.multiIndex[0] == 0 && data.multiIndex[1] == 0) {

              // let time_middle_num = Number(this.data.custom_time.start[1]) > new Date().getMinutes() ? Number(this.data.custom_time.start[1]) : new Date().getMinutes();
              // match_time_handle();
              let day = [];
              for (var i = 0; i < this.data.after_day; i++) {
                if ((new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + i)).getMonth() + 1) == (new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMonth() + 1)) {
                  day.push(new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + i)).getDate() >= 10 ? `${new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + i)).getDate()}日` : `0${new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + i)).getDate()}日`);
                }
              }
              //添加小时，小时为当前时间到结束时间，如果没有时间，天数跳到下一天，小时为开始到结束
              let middle_hour = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getHours();
              if (middle_hour >= this.data.custom_time.start[0] && middle_hour <= this.data.custom_time.end[0]) {
                //if判断四种情况，开始时间与结束时间是否相等，并处于其中范围内
                //表及地点
                // hour.push(`${}`)
                for (let i = middle_hour; i <= this.data.custom_time.end[0]; i++) {
                  hour.push(i >= 10 ? `${i}时` : `0${i}时`);
                }
                if (middle_hour == this.data.custom_time.start[0] && middle_hour != this.data.custom_time.end[0]) {
                  let time_middle_mi = 0;
                  time_middle_mi = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes() > this.data.custom_time.start[1] ? new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes() : this.data.custom_time.start[1];
                  for (var i = time_middle_mi; i < 60; i++) {
                    mi.push(i >= 10 ? `${i}分` : `0${i}分`)
                  }
                } else if (middle_hour == this.data.custom_time.end[0] && middle_hour == this.data.custom_time.start[0]) {
                  let time_middle_mi = 0;
                  time_middle_mi = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes() > this.data.custom_time.start[1] ? new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes() : this.data.custom_time.start[1];
                  for (var i = time_middle_mi; i < 60; i++) {
                    mi.push(i >= 10 ? `${i}分` : `0${i}分`)
                  }
                } else if (middle_hour == this.data.custom_time.end[0] && middle_hour != this.data.custom_time.start[0]) {
                  for (var i = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes(); i <= this.data.custom_time.end[1]; i++) {
                    mi.push(i >= 10 ? `${i}分` : `0${i}分`)
                  }
                } else {
                  for (var i = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes(); i < 60; i++) {
                    mi.push(i >= 10 ? `${i}分` : `0${i}分`)
                  }
                }

              } else if (middle_hour < this.data.custom_time.start[0]) {

                for (let i = Number(this.data.custom_time.start[0]); i < this.data.custom_time.end[0]; i++) {
                  hour.push(i >= 10 ? `${i}时` : `0${i}时`);
                }
                for (var i = Number(this.data.custom_time.start[1]); i < 60; i++) {
                  mi.push(i >= 10 ? `${i}分` : `0${i}分`)
                }
              } else {
                //没有hour，重置天数
                day = [];
                for (var i = 1; i < this.data.after_day; i++) {
                  if ((new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + i)).getMonth() + 1) == (new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMonth() + 1)) {
                    day.push(`${new Date(new Date(that.data.new_time_state ? that.data.new_time : new Date()).setDate(new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate() + i)).getDate()}日`);
                  }
                }
                for (var i = Number(this.data.custom_time.start[0]); i < this.data.custom_time.end[0]; i++) {
                  hour.push(i >= 10 ? `${i}时` : `0${i}时`);
                }
                for (var i = Number(this.data.custom_time.start[1]); i < 60; i++) {
                  mi.push(i >= 10 ? `${i}分` : `0${i}分`)
                }
              }
              // '测试数据测试日期'
            } else {
              next_time_handle();
            }
          } else {
            next_time_handle();
          }
          data.multiArray[3] = hour;
          data.multiIndex[3] = 0;
          data.multiArray[4] = mi;
          data.multiIndex[4] = 0;
          break;
        case 3: //切换小时
          if (value == 0) {
            if (data.multiIndex[0] == 0 && data.multiIndex[1] == 0 && data.multiIndex[2] == 0) {
              // console.log(data.multiArray[2][0].split('日')[0],this.data.custom_time.start);
              if ((Number(this.data.custom_time.start[0]) > new Date(that.data.new_time_state ? that.data.new_time : new Date()).getHours()) || data.multiArray[2][0].split('日')[0] != new Date(that.data.new_time_state ? that.data.new_time : new Date()).getDate()) { //开始时间大于当前时间，使用开始时间,或者是下一天的时间
                if (data.multiArray[3].length == 1) { //一开始时间为起始,结束分钟为结束时间
                  for (var i = Number(this.data.custom_time.start[1]); i < 60; i++) {
                    if (i > this.data.custom_time.start[1] && i <= this.data.custom_time.end[1]) {

                      mi.push(i >= 10 ? `${i}分` : `0${i}分`);
                    }
                  }
                } else if (data.multiArray[3].length > 1) { //使用开始时间，结束时间为50分钟
                  for (var i = Number(this.data.custom_time.start[1]); i < 60; i++) {
                    if (i >= this.data.custom_time.start[1]) {

                      mi.push(i >= 10 ? `${i}分` : `0${i}分`);
                    }
                  }
                }
              } else { //开始时间小于当前时间, 使用当前时间
                if (data.multiArray[3].length == 1) { //一开始时间为起始,结束分钟为结束时间
                  for (var i = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes(); i < 60; i++) {
                    if (i > this.data.custom_time.start[1] && i <= this.data.custom_time.end[1]) {

                      mi.push(i >= 10 ? `${i}分` : `0${i}分`);
                    }
                  }
                } else if (data.multiArray[3].length > 1) { //使用开始时间，结束时间为50分钟
                  for (var i = new Date(that.data.new_time_state ? that.data.new_time : new Date()).getMinutes(); i < 60; i++) {
                    // if (i > this.data.custom_time.start[1]) {
                      // console.log("3test");

                      mi.push(i >= 10 ? `${i}分` : `0${i}分`);
                    // }
                  }
                }
              }
            } else {
              for (var i = 0; i < mi_data.length; i++) {
                if (mi_data[i] >= this.data.custom_time.start[1] && mi_data[i] <= 60) {

                  mi.push(`${mi_data[i]}分`)
                }
              }
            }

          } else { //不等于当年当月当时
            // console.log(value, data.multiArray[3].length);
            if (value == data.multiArray[3].length - 1) { //切换到最后一个小时
              // console.log(mi_data);
              for (var i = 0; i < mi_data.length; i++) {
                if (mi_data[i] >= 0 && mi_data[i] <= this.data.custom_time.end[1]) {
                  // console.log('ce4');
                  mi.push(`${mi_data[i]}分`)
                }
              }
            } else {
              let middle_mi_data = [];
              mi_data.map(item => {

                middle_mi_data.push(`${item}分`);
              })
              mi = middle_mi_data;
            }
          }
          data.multiArray[4] = mi;
          data.multiIndex[4] = 0;
          break;
        case 4:
          ;
          break;

      }

      data.multiIndex[e.detail.column] = e.detail.value;
      // console.log(data.multiArray);
      // wx.nextTick(()=>{
      //   this.setData({
      //     multiArray:data.multiArray,
      //     multiIndex:data.multiIndex
      //   });
      //   console.log(this.data.multiArray);
      // })
      this.setData(data);
    },
    //时间选择
    bindMultiPickerChange(e) {
      let data = this.data;
      // console.log(data.multiArray[3][data.multiIndex[3]]);
      if (!data.multiArray[3][data.multiIndex[3]] || !data.multiArray[4][data.multiIndex[4]]) {
        Toast("当前时间段暂无取货时间，请选择其他时间");
      } else {
        let new_date = `${data.multiArray[0][data.multiIndex[0]]}-${data.multiArray[1][data.multiIndex[1]]}-${data.multiArray[2][data.multiIndex[2]]} ${data.multiArray[3][data.multiIndex[3]]}:${data.multiArray[4][data.multiIndex[4]]}:00秒`;
        let reg = new RegExp(/['年月日时分秒']/, 'gi');

        new_date = new_date.replace(reg, '');
        // console.log("选择的时间为",new_date);
        let middle_date_value = new_date.replace(/-/g, '/');
        let middle_date = this.data.customformatTimeTrans(middle_date_value);
        var now = new Date(middle_date_value);
        var weeks = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六");
        var day = now.getDay();
        // console.log(now)
        var week = weeks[day];
        this.setData({
          appointment: new_date,
          appointment_show: `${middle_date.m}月${middle_date.d}(${week}) ${middle_date.h}:${middle_date.mi}`
        })
        this.triggerEvent("select_time", {
          time: new_date,
          time_show: this.data.appointment_show
        });
      }
    },
    //时间选择器处理
    time_handle() {
      let day = [];
      let month_time = [];
      let year = [];
      let hour = [];
      let mi = [];

      //重置天数函数
      const resetDay = () => {
        //没有hour，重置天数,天数选择下一天
        day = [];
        hour = [];
        mi = [];
        for (var i = 1; i < this.data.after_day; i++) {
          if ((new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getMonth() + 1) == (new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMonth() + 1)) {
            day.push(`${new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getDate()}日`);
          }
        }
        for (var i = Number(this.data.custom_time.start[0]); i <= this.data.custom_time.end[0]; i++) {
          hour.push(i >= 10 ? `${i}时` : `0${i}时`);
        }
        for (var i = Number(this.data.custom_time.start[1]); i < 60; i++) {
          mi.push(i >= 10 ? `${i}分` : `0${i}分`)
        }
      }
      //求年份year
      // console.log(new Date().getFullYear())
      // console.log(new Date(new Date().setDate(new Date().getDate() + this.data.after_day)).getFullYear())
      //年份添加后七天的年份
      year.push(`${new Date(this.data.new_time_state ? this.data.new_time : new Date()).getFullYear()}年`);
      year.push(`${new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + this.data.after_day)).getFullYear()}年`);
      //去除年份中重复的年份
      year = [...new Set(year)];

      //求当前年份中的月份
      //求年份相同的月份
      for (var i = 0; i < this.data.after_day; i++) {
        if ((new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getFullYear()) == new Date(this.data.new_time_state ? this.data.new_time : new Date()).getFullYear()) {
          month_time.push(`${new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getMonth() + 1}月`);
        }
      }
      month_time = [...new Set(month_time)];
      //day应该分两种思路解决，第一是，求当月的七天后的天数，第二做一次验证如果当天没有小时，就自动加入下一天
      for (var i = 0; i < this.data.after_day; i++) {
        if ((new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getMonth() + 1) == (new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMonth() + 1)) {
          day.push(new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getDate() >= 10 ? `${new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getDate()}日` : `0${new Date(new Date(this.data.new_time_state ? this.data.new_time : new Date()).setDate(new Date(this.data.new_time_state ? this.data.new_time : new Date()).getDate() + i)).getDate()}日`);
        }
      }
      //表及地点
      //添加小时，小时为当前时间到结束时间，如果没有时间，天数跳到下一天，小时为开始到结束
      let middle_hour = new Date(this.data.new_time_state ? this.data.new_time : new Date()).getHours();
      if (middle_hour >= this.data.custom_time.start[0] && middle_hour <= this.data.custom_time.end[0]) {
        // hour.push(`${}`)
        for (let i = middle_hour; i <= this.data.custom_time.end[0]; i++) {
          hour.push(i >= 10 ? `${i}时` : `0${i}时`);
        }
        // console.log(middle_hour,this.data.custom_time.start[0])
        if (middle_hour == this.data.custom_time.start[0] && middle_hour != this.data.custom_time.end[0]) {
          let time_middle_num = Number(this.data.custom_time.start[1]) > new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes() ? Number(this.data.custom_time.start[1]) : new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes();
          for (var i = time_middle_num; i < 60; i++) {
            mi.push(i >= 10 ? `${i}分` : `0${i}分`)
          }
        } else if (middle_hour < this.data.custom_time.end[0]) {
          for (var i = new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes(); i < 60; i++) {
            mi.push(i >= 10 ? `${i}分` : `0${i}分`)
          }
        } else if (middle_hour == this.data.custom_time.end[0]) {
          if (middle_hour == this.data.custom_time.start[0]) { //开始小时等于结束小时
            let midd_time_mi = 0;
            midd_time_mi = new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes() > this.data.custom_time.start[1] ? new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes() : this.data.custom_time.start[1];
            for (var i = midd_time_mi; i <= this.data.custom_time.end[1]; i++) {
              mi.push(i >= 10 ? `${i}分` : `0${i}分`)
            }
          } else { //开始小时不等于结束小时
            let midd_time_mi = new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes();
            for (var i = midd_time_mi; i <= this.data.custom_time.end[1]; i++) {
              mi.push(i >= 10 ? `${i}分` : `0${i}分`)
            }
          }
          if (new Date(this.data.new_time_state ? this.data.new_time : new Date()).getMinutes() > this.data.custom_time.end[1]) {
            resetDay();
          }
          // console.log('测试开始到结束的时间范围');
        }
      } else if (middle_hour < this.data.custom_time.start[0]) { //在当前营业时间未开始时，选择时间

        for (let i = Number(this.data.custom_time.start[0]); i <= this.data.custom_time.end[0]; i++) {
          hour.push(i >= 10 ? `${i}时` : `0${i}时`);
        }
        for (var i = Number(this.data.custom_time.start[1]); i < 60; i++) {
          mi.push(i >= 10 ? `${i}分` : `0${i}分`)
        }
      } else { //营业时间结束、选择第二天时间
        resetDay();

      }
      day = [...new Set(day)];
      this.setData({
        multiArray: [year, month_time, day, hour,
          mi
        ],
      })

    },
  }
})